package com.example.micro.jvm.server.reflect;

import java.lang.annotation.Annotation;
import java.util.Arrays;

public class ReflectTest1 {

    public static void main(String[] args) throws ClassNotFoundException {

        //通过反射获取类的Class对象
        Class c1 = Class.forName("com.example.micro.jvm.server.reflect.UserReflect");
        System.out.println(c1);

        Annotation[] annotations = c1.getAnnotations();
        Arrays.stream(annotations).forEach(System.out::println);

        Class c2 = Class.forName("com.example.micro.jvm.server.reflect.UserReflect");

        //通过hashcode可以看出，Class对象是同一个对象，也是唯一的
        System.out.println(c1.hashCode() + " " + c2.hashCode());

    }

}
